package vul

// Columns Excel列编号，用于通过对应的索引找Axis（当前仅包含支持A-Z）
//var Columns = [26]string{
//	"A", "B", "C", "D", "E", "F", "G",
//	"H", "I", "J", "K", "L", "M", "N",
//	"O", "P", "Q", "R", "S", "T",
//	"U", "V", "W", "X", "Y", "Z"}

// DetailSheetName 漏洞扫描结果表格详细内容的Sheet页名
const DetailSheetName = "漏洞报告"
const DetailReleaseNotesSheetName = "安全漏洞列表"

const (

	// Release Notes
	HeaderReleaseNotesCVE           = "漏洞编号"
	HeaderReleaseNotesDTS           = "漏洞DTS单号"
	HeaderReleaseNotesVulDetail     = "漏洞简述"
	HeaderReleaseNotesCVSS          = "CVSS分值"
	HeaderReleaseNotesConfirmer     = "处理人"
	HeaderReleaseNotesConfirmDate   = "处理时间"
	HeaderReleaseNotesConfirmStatus = "处理状态"
	HeaderReleaseNotesVersion       = "合入版本号"
	HeaderReleaseNotesComponent     = "组件"
	HeaderReleaseNotesRemarks       = "备注"

	// 漏洞扫描结果
	HeaderComponent             = "Component"
	HeaderVersion               = "Version"
	HeaderCVE                   = "CVE"
	HeaderMatchingType          = "Matching type"
	HeaderCVSSVersion           = "CVSS Version"
	HeaderCVSS                  = "CVSS"
	HeaderCVEPublicationDate    = "CVE publication date"
	HeaderIsAffected            = "Is Affected"
	HeaderReasonType            = "Reason Type"
	HeaderRemarks               = "Remarks"
	HeaderConfirmer             = "Confirmer"
	HeaderObject                = "Object"
	HeaderObjectCompilationDate = "Object compilation date"
	HeaderObjectFullPath        = "Object full path"
)

// HeadersBefore 二进制分析结果原始Excel表格中的表头序列
var HeadersReleaseNotes = []string{
	HeaderReleaseNotesCVE,
	HeaderReleaseNotesDTS,
	HeaderReleaseNotesVulDetail,
	HeaderReleaseNotesCVSS,
	HeaderReleaseNotesConfirmer,
	HeaderReleaseNotesConfirmDate,
	HeaderReleaseNotesConfirmStatus,
	HeaderReleaseNotesVersion,
	HeaderReleaseNotesComponent,
	HeaderReleaseNotesRemarks}

var HeadersReleaseNotesIndexMap = GetHeadersIndexMap(HeadersReleaseNotes)

// HeadersBefore 二进制分析结果原始Excel表格中的表头序列
var HeadersBefore = []string{
	HeaderComponent, HeaderVersion, HeaderCVE, HeaderMatchingType, HeaderCVSSVersion, HeaderCVSS,
	HeaderCVEPublicationDate, HeaderIsAffected, HeaderReasonType, HeaderRemarks, HeaderConfirmer,
	HeaderObject, HeaderObjectCompilationDate, HeaderObjectFullPath}

// HeadersBeforeIndexMap 记录二进制分析结果原始Excel表格表头及其对应索引的字典
var HeadersBeforeIndexMap = GetHeadersIndexMap(HeadersBefore)

// HeadersAbnormalValueMap 记录而二进制分析内容与异常结果的对应关系
//var HeadersAbnormalValueMap = map[string]string{
//	HeaderBindNow: ResultNo,
//	HeaderNX:      ResultNo,
//	HeaderPIC:     ResultNo,
//	HeaderPIE:     ResultNo,
//	HeaderRELRO:   ResultNo,
//	HeaderSP:      ResultNo,
//	HeaderRpath:   ResultYes,
//	HeaderFS:      ResultToDo,
//	HeaderFtrapv:  ResultToDo,
//	HeaderStrip:   ResultToDo,
//}

// GetHeadersIndexMap 根据顺序的Excel表格头及其索引组成的字典，用来查询表头对一个的索引
func GetHeadersIndexMap(headers []string) map[string]int {
	m := map[string]int{}
	for i, header := range headers {
		m[header] = i
	}
	return m
}

// Keywords 更新路径的关键词
//var Keywords = []string{
//	"layer.tar_/layer",
//	"layer.tar_",
//}

const (
	ResultAffected      = "Affected"
	ResultUnaffected    = "Unaffected"
	ResultFalsePositive = "False positive"

	ResultAffectedReasonTypeToBeFixed  = "To be fixed"
	ResultAffectedReasonTypeNoSolution = "No solution"
	ResultAffectedReasonTypeOther      = "Other"

	ResultUnaffectedReasonTypeFeatureNotUsed = "Feature not used"
	ResultUnaffectedReasonTypePatched        = "Patched"
	ResultUnaffectedReasonTypeOther          = ResultAffectedReasonTypeOther

	ResultFalsePositiveReasonTypeIncorrectComponentVersion = "Incorrect component version"
	ResultFalsePositiveReasonTypeCVENotMatched             = "CVE not matched"
	ResultFalsePositiveReasonTypeOther                     = ResultAffectedReasonTypeOther
)

const (
	// StyleStringHeader 二进制扫描结果中表头内容的样式
	// `{"fill":{"type":"pattern","color":["#CCFFCC"],"pattern":1}, "font":{"bold":true,"italic":true,"family":"Times New Roman","size":36,"color":"#777777"}}`
	// `{"alignment":{"horizontal":"center","ident":1,"justify_last_line":true,"reading_order":0,"relative_indent":1,"shrink_to_fit":true,"text_rotation":45,"vertical":"","wrap_text":true}}`
	StyleStringHeader = `{"fill":{"type":"pattern","color":["#CCFFCC"],"pattern":1}, "font":{"bold":true}, "alignment":{"horizontal":"center"}}`

	StyleStringHeaderConfirm = `{"fill":{"type":"pattern","color":["#CCCCFF"],"pattern":1}, "font":{"bold":true}, "alignment":{"horizontal":"center"}}`

	// StyleStringPassed 二进制扫描结果中通过内容的样式
	StyleStringPassed = `{"fill":{"type":"pattern","color":["#00FF00"],"pattern":1}}`
	// StyleStringFailed 二进制扫描结果中失败内容的样式
	StyleStringFailed = `{"fill":{"type":"pattern","color":["#FF0000"],"pattern":1}}`
	// StyleStringUnused 二进制扫描结果中未使用内容的样式
	StyleStringUnused = `{"fill":{"type":"pattern","color":["#808080"],"pattern":1}}`
)
